import { reqHomePageList } from "@/api";

const state = {
  // 首页所有数据
  homePagesData: {}
}

const actions = {
  async getHomePageList({ commit }) {
    const result = await reqHomePageList();
    console.log('home页面数据', result);
    // 提交请求到的数据
    commit('GET_HOME_PAGE_LIST', result.data)
  },
}

const mutations = {
  GET_HOME_PAGE_LIST(state, payload) {

    state.homePageList = payload
  }
}

const getters = {
  // 轮播图数据
  bannerList(state) {
    return state.homePagesData?.blocks[0].extInfo.banners || [];
  }
}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}